/*
 * @Author: gavin
 * @Date:   2017-12-20 13:14:35
 * @Last Modified by:   gavin
 * @Last Modified time: 2017-12-20 13:18:31
 */

import React from 'react';
import { Switch, Route } from 'react-router-dom';

const Routers = (parentPath, routeList) => (
	<Switch>
	{
    		routeList.map((item, i) => {
	    		let config = item;
	    		if (parentPath && 'path' in item) {
	    			config.path = parentPath + item.path;
	    		}
	    		return (
	    			<Route key={i} {...config} />
	    		);
    		})
    	}
  	</Switch>
);
export default Routers;
